$(function(){
	var thisVue = View_UserArticel_Main_Vue.$data;
	//获取用户信息
	var token = localStorage.getItem("ArticleUserId");
	if (token == null) {
		location = "./LogIn.html";
	}else{
		$.get("https://localhost:44356/api/UserDetails/UserInfo", {
			Token: token,
			Index: 0
		}, function(data) {
			if (data.statusCode == 1)
				location = "./LogIn.html";
			if (data.statusCode == 0) {
				thisVue.UserInfo = data.result;
			}
			console.log(data)
		})
		//获取用户文章
		$.get("https://localhost:44356/api/Display/UserArticle", {
			Token: token,
			Index: 0
		}, function(data) {
			if (data.statusCode == 1)
				location = "./LogIn.html";
			if (data.statusCode == 0) {
				if (data.result.length == 0) {
					thisVue.ArticleIndex = -1;
					return;
				}
				thisVue.ArticleArr = data.result;
			}
			console.log(data)
		})
		//获取用户的最新消息
		$.get("https://localhost:44356/api/Latest/GetAllNotify", {
			Token: localStorage.getItem("ArticleUserId")
		}, function(data) {
			console.log(data)
			thisVue.Notify = data.result;
		})
	}
	
	
	
	//最新消息的清空
	var latestJudge = false;
	var latestDom = null;
	$("body").on("mousedown", ".IsLatest", function() {
		latestJudge = true;
		latestDom = this;
		//获取当前鼠标位置
		//快速将当前元素变成屏幕元素
		$(this).css({
			"position": "fixed",
			"top": $(this).offset().top,
			"left": $(this).offset().left
		});
	});
	$("body").mousemove(function() {
		if (latestJudge) {
			$(latestDom).css({
				"top": window.event.clientY - parseInt($(latestDom).css("height")) / 2,
				"left": window.event.clientX - parseInt($(latestDom).css("width")) / 2
			})
		}
	})
	$("body").mouseup(function() {
		if (latestJudge) {
			//生成新元素
			$(latestDom).parent().append(
				$("<span>0</span>")
			);
			//删除当前元素
			$(latestDom).remove();
			//清空库中存储
			$.get("https://localhost:44356/api/Latest/DelLike",{
				Token : localStorage.getItem("ArticleUserId")
			},function(data){
				console.log(data)
			})
	
			latestDom = null;
			latestJudge = false;
		}
	})
	
})